Skip to content

fix(skills): refuse client casts of unlearned or inactive-tree ability skills - #48

Merged
NickMesser merged 3 commits into
NickMesser:rust-rewritefrom
stsiakal:fix/refuse-unlearned-skill-casts
Oct 27, 2026
Merged

NickMesser merged 3 commits into
NickMesser:rust-rewritefrom
stsiakal:fix/refuse-unlearned-skill-casts

Conversation

@stsiakal

@stsiakal stsiakal commented Oct 27, 2026 •

Copy link
Copy Markdown

CSStartSkill accepted a learned ability-tree skill from an inactive ability and an unlearned ability-tree skill that a client-facing source table names. The 1.2 client marks both unusable in its action bar (the action-slot states canUse / learned; the server answers with the client's own result codes INVALID_SKILL 0x1e and INACTIVE_ABILITY 0x1f), while the C# handler fell through to a catch-all that cast any skill id with a template.

  • Add class_skill_denial to the client cast path: a skill with ability_id != 0 needs that ability among the three active ones (INACTIVE_ABILITY, 0x1f) and, when need_learn, the skill or a same-ability-level variant learned (INVALID_SKILL, 0x1e). Item, mount, default / common and auto-attack casts are decided before the check; GM commands use the server skill API.
  • Keep ability-less skills unrestricted: the real-data test pins that every id named by item use, buff grants, mount-attached rider skills, crafts, NPC interactions, slash commands, quest components / supply / timers, housing / shipyard steps, defaults, gimmicks, sphere skills and AI events has ability_id = 0 (5,528 known ids).
  • The only ability-tree skills a client-facing source table names are mount skill 13572 (login-stage fake, mount branch) and quest / doodad conditions 10664, 10134, 12075 and 11380; those still need the ability active and the skill learned, as the client requires.
  • Add flow tests for refused unlearned / inactive-tree casts and regression controls for learned, variant, item, mount, toggle and ability-less buff / quest / doodad casts, plus a real-data source invariant test.

The exact result codes are our choice; the client only needs a non-success SCSkillStarted.

Validation

  • Failing first: with only the test module on nick/rust-rewrite (c6befb58c), cargo test -p aaemu-game --lib class_skill_authority is 6 passed, 3 failed. The failures show the active-tree unlearned skill cast (fallback result 45, NO_PERM, instead of 30 INVALID_SKILL) and both tree cases casting (skill_last_used_ms > 0) where INACTIVE_ABILITY / INVALID_SKILL are expected.
  • With the fix: 10 passed, 0 failed, 1 ignored. cargo clippy -p aaemu-game --all-targets -- -D warnings passes.
  • The ignored real-data test (AAEMU_COMPACT_DB=D:/aaemu-live/rs-game/Data/compact.sqlite3 cargo test -p aaemu-game --lib real_data_skill_sources_do_not_smuggle_class_tree_skills -- --ignored --nocapture) passes: 15,126 skills, 170 ability-tree skills, 5,528 known ability-less source ids, 8 class-tree source rows (the five documented ids). Every item / buff / mount-attached / craft / NPC interaction / slash / quest / housing / shipyard / default / gimmick / sphere / AI-event id is ability-less.
  • Full cargo xtask ci from rust/ on the PR head: all workspace tests pass, 0 failed; game library 2,888 passed, 0 failed, 150 ignored; testclient 57 library + 16 binary tests; login library 200 passed / 1 ignored; commons 102 passed; formatting, all-target Clippy with -D warnings, the S->C coverage ratchet and the 7 Python tests pass.
  • Live on a local server stack, headless aaemu-testclient, fresh level-10 Nuian fighter (ability 1 active), same script on both binaries:
    • Before (nick/rust-rewrite c6befb5): cast 10134 3492 (ability 2, need_learn, named by sphere_doodad_interacts). The server logged 13:53:37 [INFO] handlers - StartSkill: Id 10134, flag 0, caster=33000, target=32626; the capture has SCSkillFiredPacket for 10134 and SCSkillEndedPacket, no refusal.
    • After (PR head): the same cast logs 14:09:10 [INFO] handlers - StartSkill: Id 10134, ... and 14:09:10 [WARN] handlers - Client cast of an inactive or unlearned ability skill refused character=Castafter skill_id=10134 result=31; the capture has SCSkillStartedPacket body ...00011f (skill 10134, flags 1, result 0x1f) and no SCSkillFiredPacket.
    • The stack was stopped afterwards. No original 1.2 client was launched; the bot is headless.

Limits / not claimed

  • This is not a real-client UI run. The 1.2 client refusal is cited from the client decompile: the action-slot bytecode carries canUse / learned state and the native X2::GameClient::SkillAccessor publishes learned. The decompile shows this UI state, not a refused press, and the press was not observed in a live client here. Appellation, expedition and family skills were not enumerated in the real-data invariant test.
  • A Mount caster naming the player itself still runs through the mount branch before this check (the deliberate self allowance). Only ability-tree mount skill 13572 exists there, a login-stage fake. A bind-on-pickup item caster can still name a different skill id (the legacy fireplace exception, narrowed for UCC effects). Neither bypass is closed here.
  • Class-tree skills named by quest / doodad condition tables (10664, 10134, 12075, 11380) are refused unless learned and active. That matches the client, but an unlearned bot cannot use them to advance the condition; they are not grants.
  • The live check covers one skill id and one fresh character; the item / mount / toggle / ability-less sources are covered by flow tests, not live.
  • The ignored compact-data invariant is not part of CI; it was run manually against the shared 1.2 compact copy.

Review: an independent reviewer (R1) traced every skill source through start_skill (the gate sits after the mount, auto-attack, default/common and item branches and only applies to ability_id != 0), checked the result codes against the client and the tests' red/green structure: qualified clear. Its wording corrections (UI state, not a proven refused press) are applied.

🤖 Generated with Claude Code

stsiakal and others added 3 commits October 27, 2026 13:09
CSStartSkill still casts a learned ability-tree skill from an inactive tree and
an unlearned ability-tree skill that a client-facing source table names. An
unlearned ability-tree skill with no client source is refused, but with NO_PERM
instead of the 1.2 INVALID_SKILL.

Drive CSStartSkill for the class-tree cases and keep item, mount, toggle and
ability-less buff / quest / doodad casts as regression controls.

Before the fix the focused run is 6 passed, 3 failed; the failures show the
cast happening (skill_last_used_ms > 0) and the fallback's result 45 instead of
INVALID_SKILL (30), INACTIVE_ABILITY (31) where expected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y skills

CSStartSkill trusted the client's skill id: a learned skill from an inactive
ability tree still ran, and a client-source table let an unlearned class skill
through. A skill with ability_id != 0 now needs that ability active and, when
need_learn, the skill or a same-ability-level variant learned. Item, mount,
default / common and auto-attack casts stay ahead of the check; ability-less
buff, quest, doodad, craft, NPC interaction, slash and housing / shipyard skills
are untouched, and a real-data test pins that every id those tables name is
ability-less.

The 1.2 client enforces this in its action bar (learned / canUse states,
URK_TRAINED_SKILL); the C# catch-all cast any skill id. Result codes are
INVALID_SKILL (0x1e) for unlearned and INACTIVE_ABILITY (0x1f) for an inactive
tree; the client only needs a non-success SCSkillStarted.

Focused run: 10 passed, 1 ignored; the ignored compact-data invariant test
passes separately. The new test module alone is 6 passed, 3 failed before this
fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… refusals

The client decompile shows the action slot's canUse/learned UI state and
the INVALID_SKILL / INACTIVE_ABILITY result codes; it does not show the
press itself being refused, and URK_TRAINED_SKILL is a unit-requirement
label, not a cast result. Say exactly that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@NickMesser
NickMesser merged commit 923f104 into NickMesser:rust-rewrite Oct 27, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants